package com.xy.biz.base.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.base.domain.bo.CorpBO;
import com.xy.biz.base.domain.po.CorpPO;
import com.xy.biz.base.domain.query.CorpQuery;
import com.xy.biz.base.domain.dto.CorpDTO;
import com.xy.biz.base.domain.req.SaveCorpRequest;
import com.xy.biz.base.domain.req.ListCorpRequest;

/**
 * 
 * 
 * @author zsp
 * @date 2020-9-3
 */
public class CorpConverter {
	
	public static CorpPO toPO(CorpBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new CorpPO(), true);
	}
	
	public static List<CorpPO> toPO(Collection<CorpBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new CorpPO(), true);
	}
	
	public static CorpBO fromPO(CorpPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new CorpBO());
	}
	
	public static List<CorpBO> fromPO(Collection<CorpPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new CorpBO());
	}
	
	public static CorpBO toBO(SaveCorpRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new CorpBO(), true);
	}
	
	public static List<CorpBO> toBO(Collection<SaveCorpRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new CorpBO(), true);
	}
	
	public static CorpDTO toDTO(CorpBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new CorpDTO());
	}
	
	public static List<CorpDTO> toDTO(Collection<CorpBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new CorpDTO());
	}
	
	public static CorpQuery toQuery(ListCorpRequest source) {
		if(null == source) {
			return null;
		}
		CorpQuery target = new CorpQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
